<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>平台审核报关行自主报价列表</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript" src="<s:url value="../js/ajaxutil.js"/>"></script>
</head>
<script type="text/javascript">
    // 	var bstate = "${param.declaraState }";
    // 	var comId = "${sessionScope.CURRENT_USER.company.id}";
    var businessType = [["提交", "OS01"], ["已确认", "OS02"],
        ["驳回", "OS03"], ["结束", "OS04"], ["报价生效", "OS05"]];
    var formSetting = {
        title: "查询报关报关行报价信息",
        module: 'query',
        columns: [{
            name: "offerId",
            label: "业务编码"
        }, {
            name: "state",
            label: "状态",
            type: "dropdown",
            data: businessType
// 			dropdownType:"ajax",
// 			url:"../base/dropdown-declarationState",
// 			op:"eq",
// 			minLength:0
        }, {
            name: "reg_user",
            label: "报价人"
        }],
        buttons: {
            custom: [
                {
                    id: "updateBtn",
                    value: "查看并确认报价",
                    click: function () {
                        var selectedRowId = $("#declarationsOfferDataGrid").getGridParam("selrow");
                        if (selectedRowId) {
                            var selectedRow = $("#declarationsOfferDataGrid").getRowData(
                                    selectedRowId);
                            location.href =
                                    "declarationOffer-declarationOfferSupManage?id="
                                    + selectedRow.id;
                        } else {
                            alert("请选择需要修改的记录!")
                        }
                    }
                }]
        },
        grid: {
            id: "declarationsOfferDataGrid",
            title: "查询结果",
            url: "declarationOffer-findSupList",
            //multiselect : true,
            /* postData : {
             "pid" : pid
             }, */
// 			postData : {
// 				"declaraState" : bstate
// 			},
            colModel: [{
                index: "ID",
                name: "id",
                hidden: true
            }, {
                index: "declaration_company",
                name: "declaration_company",
                label: "报价公司名"
            }, {
                index: "container_amount",
                name: "container_amount",
                label: "出口免报关费柜数",
                hidden: true
            }, {
                index: "imp_container_amount",
                name: "imp_container_amount",
                label: "免报关费柜数",
                hidden: true
            }, {
                index: "declaration_amount",
                name: "declaration_amount",
                label: "出口报关金额 / 免费柜数",
                formatter: function (val, options, row) {
                    if (val == undefined) {
                        return "--";
                    }
                    var ca = row.container_amount;
                    var container_amount_ = ca == 0 || ca == undefined ? '--' : ca;
                    return val + " / " + container_amount_;
                }
            }, {
                index: "imp_declaration_amount",
                name: "imp_declaration_amount",
                label: "进口报关金额 / 免费柜数",
                formatter: function (val, options, row) {
                    if (val == undefined) {
                        return "--";
                    }
                    var ca = row.imp_container_amount;
                    var container_amount_ = ca == 0 || ca == undefined ? '--' : ca;
                    return val + " / " + container_amount_;
                }
            }, {
                index: "price_begin_time",
                name: "price_begin_time",
                label: "价格开始时间",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d',
                    newformat: 'Y-m-d'
                }
            }, {
                index: "price_end_time",
                name: "price_end_time",
                label: "价格结束时间",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d',
                    newformat: 'Y-m-d'
                }
            }, {
                index: "confirmTime",
                name: "confirmTime",
                label: "提交时间",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                }
            }, {
                index: "confirm_user",
                name: "confirm_user",
                label: "提交人"
            }, {
                index: "review_date",
                name: "review_date",
                label: "确认报价时间",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                }
            }, {
                index: "review_user",
                name: "review_user",
                label: "确认报价人"
            }, {
                index: "state",
                name: "state",
                label: "状态",
                //字段值的显示格式转换
                formatter: function (cellvalue, options, row) {
                    var colorRgbMap = {
                        "草稿": "black",
                        "提交": "black",
                        "已确认": "black",
                        "驳回": "black",
                        "结束": "black",
                        "报价生效": "blue",
                        "待生效": "green",
                        "报价已过期": "red"
                    };
                    return "<label style='color:" + colorRgbMap[row.stateLabel] + "'>"
                           + row.stateLabel
                           + "</label>";
                }
            }],

            sortname: "confirmTime",
            sortorder: "desc",
            jsonReader: {
//                root: "declarationOffers"
            },
            loadComplete: function (data) {
            },
        }
    };
    $(document).ready(function () {
        $("#declarationsOfferDataTable").mrdForm(formSetting);
    });
</script>
<body>
<div id="declarationsOfferDataTable"></div>
<%-- 	<input id="companyId" type="hidden" value="${companyId }"/> --%>
</body>
</html>
